﻿using System;
using System.Reflection;
using System.Web.Mvc;
using log4net;
using QAS.Nekorama.Filters;


namespace QAS.Nekorama.Controllers
{
    /// <summary>
    ///ホームコントローラー
    /// </summary>
    [InitializeSimpleMembership]
    public class HomeController : Controller
    {
        private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// サイトの言語が変更されます。
        /// </summary>
        /// <param name="culture">#vi-VN, #en-US, #ja-JP</param>
        public void ChangeCulture(string culture)
        {
            _log.Debug("Start action " + MethodBase.GetCurrentMethod().Name);
            Session["culture"] = culture;
            _log.Debug(string.Format("change culture to {0}", culture));
            _log.Debug("End action " + MethodBase.GetCurrentMethod().Name);
        }

        /// <summary>
        ///猫ラマに必要な情報が含みます。
        /// </summary>
        /// <returns>Helpビュー</returns>
        public ActionResult Help()
        {
            _log.Debug("Start action " + MethodBase.GetCurrentMethod().Name);
            ViewBag.Message = "Your help page.";
            _log.Debug("End action " + MethodBase.GetCurrentMethod().Name);
            return View();
        }
        protected override void OnException(ExceptionContext filterContext)
        {
            filterContext.Exception = new Exception("");
            filterContext.ExceptionHandled = true;
            filterContext.Result = View("Error", new HandleErrorInfo(filterContext.Exception, "Question", "Details"));
        }
    }
}